﻿using ReflectionStudio.Controls;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Linq;
using System.Xml.Linq;
using WPFExcelReport;
using INTEX.DataBase;
using System.Windows;
using System.Windows.Controls;
using WPFExcelReport.Helpers;
using ReflectionStudio.Core.Events;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXBL
    {
        public DataSet QueryVV(string MANDANT, string KRS, string LFD)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataRow dwData;
            DataRow dwVK04 = null;
            dwData = INTEXDB.ICC_QUERYTB.NewRow();
            try
            {
                string vvliefsch = "";
                dwData["VVTMANDANT"] = MANDANT;
                dwData["VVTAUFKRS"] = KRS;
                dwData["VVTAUFLFD"] = LFD;
                SResult = INTEXDBC.QueryVVTLIEF(dwData, 2);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVVLIEF(dwData, 3);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVERSART(dwData, 2);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVVPACK(dwData, 2);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryGPACK(dwData, 2);
                SReturn.Merge(SResult);
                dwData["ZUMANDANT"] = MANDANT;
                dwData["ZUAUFKRS"] = KRS;
                dwData["ZUAUFLFD"] = LFD;
                SResult = INTEXDBC.QueryZUTEI(dwData, 3);//所有留位的
                SReturn.Merge(SResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }

            return SReturn;
        }
        public DataSet QueryVV(string MANDANT, string VVSTATUS, string DSTART, string DEND)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            DataRow dwData;
            DataRow dwVK04 = null;
            dwData = INTEXDB.ICC_QUERYTB.NewRow();
            try
            {
                dwData["VVTMANDANT"] = MANDANT;
                dwData["C20"] = VVSTATUS; 
                dwData["DSTART"] = DSTART;
                dwData["DEND"] = DEND;      
                SResult = INTEXDBC.QueryVVTLIEF(dwData, 5);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVVLIEF(dwData, 5);
                SResult.Tables[0].TableName = "PVVLIEF";
                SReturn.Merge(SResult);
                if (VVSTATUS.Contains("EN"))
                {
                    SResult = INTEXDBC.QueryVVLIEF(dwData, 7);
                    SReturn.Merge(SResult);
                }
                else
                {
                    SResult = INTEXDBC.QueryVVLIEF(dwData, 6);
                    SReturn.Merge(SResult); 
                }
                SResult = INTEXDBC.QueryVKPOS(dwData, 9);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVKZUAB(dwData, 1);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVERSART(dwData, 3);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryKDANSP(dwData, 2);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryVVPACK(dwData, 3);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryKDSTAMM(dwData, 3);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryKUNDADR(dwData, 3);
                SReturn.Merge(SResult);
                SResult = INTEXDBC.QueryGPACK(dwData, 3);
                SReturn.Merge(SResult); 
                SResult = INTEXDBC.QueryZUTEI(dwData, 7);//所有留位的
                SReturn.Merge(SResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ABPOS + ex.StackTrace, ex);
            }

            return SReturn;
        }
    }
}